From: Richard M. Stallman Date: Sun, 16 May 1993 22:31:04 +0000 (+0000) Subject: (compute_char_face): Pass 0 as EXTEND arg to overlays_at. X-Git-Tag: archive/raspbian/1%29.2+1-2+rpi1^2~5^2~96222 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:///%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:/?a=commitdiff_plain;h=9516fe943a05f036b42305626e68ae9ce3dd6d1c;p=emacs.git (compute_char_face): Pass 0 as EXTEND arg to overlays_at. Try first with small overlay_vec, then use a big enough one. --- diff --git a/src/xfaces.c b/src/xfaces.c index e450b3aa8e5..febafc8066a 100644 --- a/src/xfaces.c +++ b/src/xfaces.c @@ -136,6 +136,8 @@ int next_face_id; /* The number of the face to use to indicate the region. */ int region_face; +/* This is what appears in a slot in a face to signify that the face + does not specify that display aspect. */ #define FACE_DEFAULT (~0) Lisp_Object Qface, Qwindow, Qpriority; @@ -638,7 +640,6 @@ compute_char_face (f, w, pos, region_beg, region_end, endptr) int i, j, noverlays; int facecode; Lisp_Object *overlay_vec; - int len; struct sortvec *sortvec; Lisp_Object frame; int endpos; @@ -666,10 +667,23 @@ compute_char_face (f, w, pos, region_beg, region_end, endptr) { int next_overlay; + int len; + + /* First try with room for 40 overlays. */ + len = 40; + overlay_vec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object)); + + noverlays = overlays_at (pos, 0, &overlay_vec, &len, &next_overlay); + + /* If there are more than 40, + make enough space for all, and try again. */ + if (noverlays > len) + { + len = noverlays; + overlay_vec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object)); + noverlays = overlays_at (pos, 0, &overlay_vec, &len, &next_overlay); + } - len = 10; - overlay_vec = (Lisp_Object *) xmalloc (len * sizeof (Lisp_Object)); - noverlays = overlays_at (pos, &overlay_vec, &len, &next_overlay); if (next_overlay < endpos) endpos = next_overlay; } @@ -763,8 +777,6 @@ compute_char_face (f, w, pos, region_beg, region_end, endptr) merge_faces (FRAME_FACES (f) [region_face], &face); } - xfree (overlay_vec); - *endptr = endpos; return intern_frame_face (f, &face);